﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HSM.Web.UI;
using System.Xml;
using System.Web.Caching;

/// <summary>
/// Summary description for CacheManager
/// </summary>
public class HSMCacheManager
{
    public static UrlRewriteConfigCollection LoginUrlConfigs
    {
        get 
        {
            if (HttpRuntime.Cache["HSMCacheManager.LoginUrlConfigs"] == null)
            {
                HttpRuntime.Cache["HSMCacheManager.LoginUrlConfigs"] = UrlRewriteConfig.LoadUrlConfig();
            }
            return (UrlRewriteConfigCollection)HttpRuntime.Cache["HSMCacheManager.LoginUrlConfigs"];
        }
    }

    public static void setHotelContextMenu(string xmlPath, XmlDocument value)
    {
        string xmlFile = HttpContext.Current.Server.MapPath(xmlPath);
        HttpRuntime.Cache.Add("HSMCacheManager.HotelContextMenu." + xmlPath, value, new CacheDependency(xmlFile), Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
    }
    public static XmlDocument getHotelContextMenu(string xmlPath)
    {
        return HttpRuntime.Cache["HSMCacheManager.HotelContextMenu." + xmlPath] as XmlDocument;
    }
}
